auto.waitFor();

// console.show();
//设置屏幕的宽度，像素值
var screen_width = device.width;
//设置屏幕的高度，像素值
var screen_height = device.height
setScreenMetrics(screen_width, screen_height);
const { textCpClick } = require("./myCommonFunction.js");
var myFunc = require("./myCommonFunction.js");


threads.start(function () {
    sleep(600000)
    exit();
});
opreate();
exit();
function opreate() {
    var ret = myFunc.initNetWork(null, true);
    if (ret) {
        var shengying = device.getMusicVolume();
        device.setMusicVolume(0);
        jingdong();
        device.setMusicVolume(shengying);
    }
}
function jingdong() {
    try {
        doWork();
    } catch (error) {
        log(error);
        myFunc.tuichu("京东");
        jingdong();
    }

}

function doWork(){
    myFunc.openMyApp("京东");
    sleep(1000)
    if (!myFunc.clickByText('我的')) {
        click(1314, 3027);
    }
    sleep(2000);
    myFunc.clickByText('会员店');
    sleep(5000);
    click(736,1140);
    sleep(7000);
    text('幸福小店').findOnce().click();
    click(565,414);
    sleep(2000);
    for (let index = 0; index < 23; index++) {
        click(1167,1204);
        sleep(5000);
        myFunc.tuichuToStr('幸福小店');
        sleep(2000);
        click(1167,1204);
        sleep(2000);
    }
    var now = new Date();
    if(now.getDay() == 6){
        click(647,529);
        sleep(1500);
        click(1156,2510);
        sleep(1500);
        myFunc.clickByText('微信');
        sleep(3000);
        back();
        for (let index = 0; index < 9; index++) {
            click(565,414);
            sleep(2000);
            click(647,529);
            sleep(1500);
            click(1156,2510);
            sleep(1500);
            myFunc.clickByText('微信');
            sleep(3000);
            back();
        }
    }

}